package com.xomily.devops.agent;

import java.nio.charset.Charset;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.client.RestTemplate;

/**
 * @version V1.0
 * @ClassName:XomilyDevopsAgentApplication.java
 * @author: xomily (2327742507@qq.com)
 * @date: 2021年11月16日
 * @Description: ScheduledTask.java
 * @Copyright: 2021-2022 www.xomily.com. All rights reserved.
 */
@SpringBootApplication
@ComponentScan(basePackages = "com.xomily.devops.agent")
@EnableCaching
@EnableScheduling
public class XomilyDevopsAgentApplication {

	public static void main(String[] args) {
		SpringApplication.run(XomilyDevopsAgentApplication.class, args);
		System.out.println(" ************************  ");
        System.out.println(" 小米粒运维通Agent启动成功  ");
		System.out.println(" ************************  ");
	}
    @Bean
    public RestTemplate restTemplate() {
        StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
        RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build();
        return restTemplate;
    }

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(10);
        return taskScheduler;
    }
}
